package io.bba.boot.system.controller;

import io.bba.boot.framework.page.Paging;
import io.bba.boot.framework.response.ApiResult;
import io.bba.boot.system.query.AppSysBannerQuery;
import io.bba.boot.system.service.SysBannerService;
import io.bba.boot.system.vo.AppSysBannerVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * App系统轮播图 控制器
 *
 * @author xxcj
 * @since 2024-03-13
 */
@Slf4j
@RestController
@Tag(name = "App系统轮播图")
@RequestMapping("/app/sysBanner")
public class AppSysBannerController {

    @Autowired
    private SysBannerService sysBannerService;

    /**
     * 获取App系统轮播图详情
     *
     * @param id
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App系统轮播图详情")
    @PostMapping("/getAppSysBanner/{id}")
    public ApiResult<AppSysBannerVo> getAppSysBanner(@PathVariable Long id) {
        log.info("获取App系统轮播图详情：{}", id);
        AppSysBannerVo appSysBannerVo = sysBannerService.getAppSysBannerById(id);
        return ApiResult.success(appSysBannerVo);
    }

    /**
     * 获取App系统轮播图分页列表
     *
     * query
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App系统轮播图分页列表")
    @PostMapping("/getAppSysBannerPage")
    public ApiResult<AppSysBannerVo> getAppSysBannerPage(@Valid @RequestBody AppSysBannerQuery query) {
        log.info("获取App系统轮播图分页列表：{}", query);
        Paging<AppSysBannerVo> paging = sysBannerService.getAppSysBannerPage(query);
        return ApiResult.success(paging);
    }

}
